package org.springframework.amqp.tutorials;

import org.springframework.amqp.tutorials.config.direct.DirectSender;
import org.springframework.amqp.tutorials.config.fanout.FanoutSender;
import org.springframework.amqp.tutorials.config.headers.HeaderSend;
import org.springframework.amqp.tutorials.config.topic.TopicSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WebController {

    @Autowired
    DirectSender directSender;
    @Autowired
    TopicSender topicSender;
    @Autowired
    FanoutSender fanoutSender;
    @Autowired
    HeaderSend headerService;

    @GetMapping("directSendMsg")
    public String directSendMsg() {
        directSender.send();
        return "ok,发送成功";
    }

    @GetMapping("topicSendMsgtoStudent")
    public String topicSendMsgToStudent() {
        topicSender.topicSendMsgToStudent();
        return "ok，发送成功";
    }

    @GetMapping("topicSendMsgToTeacher")
    public String topicSendMsgToTeacher() {
        topicSender.topicSendMsgToTeacher();
        return "ok,发送成功";
    }

    @GetMapping("fanoutSendMsg")
    public String fanoutSendMsg() {
        fanoutSender.send();
        return "ok,发送成功";
    }


    @GetMapping("/send1/{msg}")
    public void send1(@PathVariable String msg) {
        headerService.send1(msg);
    }

    @GetMapping("/send2/{msg}")
    public void send2(@PathVariable String msg) {
        headerService.send2(msg);
    }

}